﻿Imports System.Xml

Namespace Spreads
	Public Class RasterVectorBalance
		Private _value As Double

		Public Property FlattenerLevel As FlattenerLevel

		Public Property Value As Double
			Get
				Return _value
			End Get
			Set(value As Double)
				If value >= 0 And value <= 100 Then
					_value = value
				End If
			End Set
		End Property

		Public Shared Function ReadXml(reader As XmlReader) As RasterVectorBalance
			Dim rvb As New RasterVectorBalance()

			If reader.HasAttributes() Then
				If reader.GetAttribute("type") = "enum" Then
					rvb.FlattenerLevel = Parser.ParseEnum(Of FlattenerLevel)(reader.ReadElementContentAsString())
				ElseIf reader.GetAttribute("type") = "double" Then
					rvb.Value = Parser.ParseDouble(reader.ReadElementContentAsString())
				End If
			End If

			Return rvb
		End Function
	End Class
End Namespace